<?php
class Avatar_Model_DbTable_Avatarcollections extends Engine_Db_Table {
	protected $_rowClass = 'Avatar_Model_Avatarcollection';
	
	public function fetchAll($order = null, $count = null, $offset = null) {
		$rName = $this->info ( 'name' );
		$select = $this->select ()->from ( $rName, array ('*', 'count_avatars' => 'COUNT(DISTINCT `engine4_avatar_avatars`.`avatar_id`)' ) )->joinLeftUsing ( 'engine4_avatar_avatars', 'avatarcollection_id', array () )->group ( "$rName.avatarcollection_id" );
		
		return parent::fetchAll ( $select, $order, $count, $offset );
	}
}